<template>
    <div>
        <el-progress :percentage="per" v-bind="$attrs" />
    </div>
</template>
<script lang="ts" setup>
import { onMounted, ref } from 'vue';
let props = defineProps({
    percentage: {
        type: Number,
        default: 0,
    },
    isAnimate: {
        type: Boolean,
        default: false,
    },
    time: {
        type: Number,
        default: 3000,
    },
});
let per = ref(0);
onMounted(() => {
    if (props.isAnimate) {
        // 规定时间内加载完成
        let time = Math.ceil(props.time / props.percentage);
        let timer = setInterval(() => {
            per.value += 1;
            if (per.value >= props.percentage) {
                per.value = props.percentage;
                clearInterval(timer);
            }
        }, time);
    } else {
        per.value = props.percentage;
    }
});
</script>

<style lang="less" scoped></style>
